package ch.ethz.inf.shop.model;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;

import ch.ethz.inf.shop.Title;

public class Recipe {
	@Title(text = "RecipeId", isVisible = false)
	final private int recipeId;
	@Title(text = "Name", isVisible = true)
	final private String name;
	@Title(text = "Preparation Time", isVisible = true)
	final private java.sql.Time preparationTime;
	@Title(text = "Instructions", isVisible = true)
	final private String instructions;

	@Title(text = "Total cost of ingredients", isVisible = true)
	final private BigDecimal costOfIngredients;

	@Title(text = "Items", isVisible = false)
	final private List<RecipeItem> items = new ArrayList<RecipeItem>();

	public int getRecipeId() {
		return recipeId;
	}

	public String getName() {
		return name;
	}

	public java.sql.Time getPreparationTime() {
		return preparationTime;
	}

	public String getInstructions() {
		return instructions;
	}

	public BigDecimal getCostOfIngredients() {
		return costOfIngredients;
	}

	public List<RecipeItem> getItems() {
		return items;
	}

	public Recipe(int recipeId, String name, Time preparationTime, String instructions, BigDecimal costOfIngredients) {
		this.recipeId = recipeId;
		this.name = name;
		this.preparationTime = preparationTime;
		this.instructions = instructions;
		this.costOfIngredients = costOfIngredients;
	}

	public Recipe(final ResultSet rs) throws SQLException {
		this.recipeId = rs.getInt("recipe_id");
		this.name = rs.getString("name");
		this.preparationTime = rs.getTime("preparation_time");
		this.instructions = rs.getString("instructions");
		this.costOfIngredients = rs.getBigDecimal("cost_of_ingredients");
	}

}
